﻿Imports System.Data.OleDb
Public Class AddNews
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub tb_news_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles tb_news.TextChanged

    End Sub

    Protected Sub btn_News_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_News.Click

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("PlayersConnectionString").ConnectionString)
        Dim SqlString As String = "Insert into News(Author,Subject,News,AddedDate) Values (@f1,@f2,@f3,NOW())"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)

        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", tb_Subject.Text)
        cmd.Parameters.AddWithValue("@f3", tb_news.Text)
        oleDbConn.Open()


        cmd.ExecuteNonQuery()
        oleDbConn.Close()
        cmd.Dispose()
        oleDbConn.Dispose()
        Response.Redirect("News.aspx")
    End Sub




End Class